// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        prefabLeven: cc.Prefab,
        objPanel:cc.Node,
    },



     onLoad () {
        window.initGameConfigData();
     },

    start() {

    },
    onJsonBtnClick(event) {
        let btnName = event.target.name;
        switch (btnName) {
            case "btn_xg":
                cc.log("加载选关界面");
                event.interactable = false;
                this.loadLevenToScene();
                break;
            default:
                cc.log("无对应按钮");
                break;
        }
    },

    loadLevenToScene() {

        var objLeven = cc.instantiate(this.prefabLeven);
        objLeven.name="objLevel";
        this.node.addChild(objLeven);
        var objLevenCom = objLeven.getComponent("LevelScene");
        objLevenCom.createLevelLayer();
        // // var levelData = window.getGameLevelDataConfig(36);
        // //大关数组
        // var groupAreaDatas = [];
        // var objLeven = cc.instantiate(this.prefabLeven);
        // objLeven.name="objLevel";

        // this.node.addChild(objLeven);

        // for (let index = 1; index < 37; index++) {
        //     var levelData = window.getGameLevelDataConfig(index);
        //     groupAreaDatas.push(levelData);
        //     //如果满了一大关创建
        //     if (groupAreaDatas.length === 6) {

        //         var objLevenCom = objLeven.getComponent("LevelScene");
        //         objLevenCom.createLevelLayer(groupAreaDatas);
        //         groupAreaDatas=[];
        //     }
        //     // cc.log("groupAreaDatas:"+groupAreaDatas);
        // }
    },

    popShow(objNode) {
        objNode.scale = 0.1;
        var scaleTo = cc.scaleTo(0.3, 1.0);
        var easeOut = scaleTo.easing(cc.easeBackOut());
        objNode.active = true;
        objNode.runAction(cc.sequence(easeOut, cc.callFunc(function () {
            cc.log("动作完成");
        })));
    }

});